package com.lemobar.pay.model.wxpay.response;

import lombok.Data;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;


/**
 * 查询订单 返回
 * JSAPI https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2
 * APP支付 https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_2&index=4
 * 小程序支付 https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_2
 * 付款码支付 https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_2
 */
@Data
@Root(name = "xml", strict = false)
public class WxPayQueryResponse {

    @Element(name = "return_code")
    private String returnCode;

    @Element(name = "return_msg")
    private String returnMsg;

    /* 以下字段在return_code为SUCCESS的时候有返回. */

    @Element(name = "appid", required = false)
    private String appid;

    @Element(name = "mch_id", required = false)
    private String mchId;

    @Element(name = "nonce_str", required = false)
    private String nonceStr;

    @Element(name = "sign", required = false)
    private String sign;

    @Element(name = "result_code", required = false)
    private String resultCode;

    @Element(name = "err_code", required = false)
    private String errCode;

    @Element(name = "err_code_des", required = false)
    private String errCodeDes;

    @Element(name = "device_info", required = false)
    private String deviceInfo;

    @Element(name = "openid", required = false)
    private String openid;

    @Element(name = "is_subscribe", required = false)
    private String isSubscribe;

    /**
     * 交易状态/订单状态
     * @see com.lemobar.pay.enums.WxPayTradeStatusEnum
     *  SUCCESS--支付成功
     *  REFUND--转入退款
     *  NOTPAY--未支付
     *  CLOSED--已关闭
     *  REVOKED--已撤销(刷卡支付)
     *  USERPAYING--用户支付中
     *  PAYERROR--支付失败(其他原因，如银行返回失败)
     *  ACCEPT--已接收，等待扣款
     */
    @Element(name = "trade_type", required = false)
    private String tradeType;

    @Element(name = "trade_state", required = false)
    private String tradeState;

    @Element(name = "bank_type", required = false)
    private String bankType;

    @Element(name = "total_fee", required = false)
    private Integer totalFee;

    @Element(name = "settlement_total_fee", required = false)
    private String settlementTotalFee;

    @Element(name = "fee_type", required = false)
    private String feeType;

    @Element(name = "cash_fee", required = false)
    private String cashFee;

    @Element(name = "cash_fee_type", required = false)
    private String cashFeeType;

    @Element(name = "coupon_fee", required = false)
    private String couponFee;

    @Element(name = "coupon_count", required = false)
    private String couponCount;

    /**
     * coupon_type_$n
     * coupon_id_$n
     * coupon_fee_$n
     */

    /**
     * 微信支付订单号
     */
    @Element(name = "transaction_id", required = false)
    private String transactionId;

    /**
     * 商户订单号
     */
    @Element(name = "out_trade_no", required = false)
    private String outTradeNo;

    @Element(name = "attach", required = false)
    private String attach;

    @Element(name = "time_end", required = false)
    private String timeEnd;

    @Element(name = "trade_state_desc", required = false)
    private String tradeStateDesc;
}
